package com.xgf.common.xgfcommon.utils;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

/**
 * 第一章关键例子，测试俩种不同构造区域数据的性能对比
 * @author xiandafu ,公众号 java系统优化
 */
@BenchmarkMode(Mode.Throughput)
@Warmup(iterations = 3)
@Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS)
@Threads(1)
@Fork(1)
@OutputTimeUnit(TimeUnit.SECONDS)
@State(Scope.Benchmark)
public class MyBenchmark {

//	@Param({"1","31","91","127","800","487987987"})
//	int status = 1;
    
    @Benchmark
    public  String  testStringKey() throws InterruptedException, ExecutionException{
    	//有返回值
	    return DateUtils.format(new Date());
    }
    @Benchmark
    public  String  testObjectKey(){
    	SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
    	return simpleDateFormat.format(new Date());
    }


    public static void main(String[] args) throws RunnerException {
        Options opt = new OptionsBuilder()
                .include(MyBenchmark.class. getSimpleName())
                .build();
        new Runner(opt).run();
    }
}
